package cn.edu.ysu.zry.entity;

import cn.edu.ysu.zry.util.RSACoder;
import cn.edu.ysu.zry.util.SHA256;

import java.util.Arrays;

/**
 * @program: XieyiBlockChainOS
 * @description: 协议对象，是区块链系统中的最小数据单元。
 * @author: Ruiyuan Zhang
 * @create: 2020-04-20 12:18
 */
public class Xieyi {
    // 发布协议端公钥
    public byte publicKeyPublish[]=new byte[RSACoder.PUBLIC_KEY_LENGTH];
    // 接受协议端公钥
    public byte publicKeyAccept[]=new byte[RSACoder.PUBLIC_KEY_LENGTH];
    // 协议内容hash值
    public byte hashXieyi[]=new byte[SHA256.HASH_LENGTH];
    // 发布协议端的私钥签名
    public byte signPublish[]=new byte[RSACoder.SIGN_LENGTH_PRIVATE_KEY];
    // 接受协议端的私钥签名
    public byte signAccept[]=new byte[RSACoder.SIGN_LENGTH_PRIVATE_KEY];
    // 协议对象的所有属性的hash值
    public byte hashXieyiAll[]=new byte[SHA256.HASH_LENGTH];

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Xieyi xieyi = (Xieyi) o;
        return Arrays.equals(hashXieyiAll, xieyi.hashXieyiAll);  //该方法不确定准确性
    }

    /**
     * getter and setter
     */
    public byte[] getPublicKeyPublish() {
        return publicKeyPublish;
    }

    public void setPublicKeyPublish(byte[] publicKeyPublish) {
        this.publicKeyPublish = publicKeyPublish;
    }

    public byte[] getPublicKeyAccept() {
        return publicKeyAccept;
    }

    public void setPublicKeyAccept(byte[] publicKeyAccept) {
        this.publicKeyAccept = publicKeyAccept;
    }

    public byte[] getHashXieyi() {
        return hashXieyi;
    }

    public void setHashXieyi(byte[] hashXieyi) {
        this.hashXieyi = hashXieyi;
    }

    public byte[] getSignPublish() {
        return signPublish;
    }

    public void setSignPublish(byte[] signPublish) {
        this.signPublish = signPublish;
    }

    public byte[] getSignAccept() {
        return signAccept;
    }

    public void setSignAccept(byte[] signAccept) {
        this.signAccept = signAccept;
    }

    public byte[] getHashXieyiAll() {
        return hashXieyiAll;
    }

    public void setHashXieyiAll(byte[] hashXieyiAll) {
        this.hashXieyiAll = hashXieyiAll;
    }
}
